# example9_4_format.py

'''在例子 9-4 之后的代码示例，但是书中没有没有给标注'''

'''
>>> brl = 1/2.43
>>> brl
0.4115226337448559
>>> format(brl, '0.4f')
'0.4115'
>>> '1 BRL = {rate:0.2f} USD'.format(rate=brl)
'1 BRL = 0.41 USD'
'''

'''
>>> format(42, 'b')
'101010'
>>> format(2/3, '.1%')
'66.7%'
'''

'''
>>> from datetime import datetime
>>> now = datetime.now()
>>> format(now, '%H:%M:%S')
'22:07:47'
>>> "It's now {:%I:%M %p}".format(now)
"It's now 10:07 PM"
'''

'''
>>> import sys
>>> sys.path.append('F:\\wxg103\\pythonProjects\\FluentPython\\ch09')
>>> from example9_3 import Vector2d
>>>
>>> v1 = Vector2d(3, 4)
>>> format(v1)
'(3.0, 4.0)'
>>>
>>> format(v1, '.3f')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported format string passed to Vector2d.__format__
'''

'''
>>> from example9_5 import Vector2d
>>> v1 = Vector2d(3, 4)
>>> format(v1)
'(3.0, 4.0)'
>>> format(v1, '.2f')
'(3.00, 4.00)'
>>> format(v1, '.3e')
'(3.000e+00, 4.000e+00)'
'''

'''
>>> sys.path.append('F:\\wxg103\\pythonProjects\\FluentPython\\ch09')
>>> from example9_6 import Vector2d
>>>
>>> format(Vector2d(1, 1), 'p')
'<1.4142135623730951, 0.7853981633974483>'
>>> format(Vector2d(1, 1), '.3ep')
'<1.414e+00, 7.854e-01>'
>>> format(Vector2d(1, 1), '0.5fp')
'<1.41421, 0.78540>'
'''




